<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
<#assign base=request.contextPath  />
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/frame/static/css/style.css">
    <link rel="icon" href="${base}/frame/static/image/code.png">
    <script type="text/javascript" src="${base}/frame/layui/layui.all.js"></script>
<#--<script type="text/javascript" src="${base}/js/zhang.js"></script>-->
<#--<script type="text/javascript" src="../frame/layui/layui.all.js"></script>-->
    <script src="${base}/js/jquery-1.8.3.min.js"></script>

</head>

<body class="body">
<div class="ziyemianbiju">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
        <div class="my-btn-box">
            <span class="fl" id="layerDemo">
                <a class="layui-btn  layui-btn-sm layui-btn-danger" id="btn-delete-all"  onclick="deleteAll()">批量删除</a>
				<#--<a  class="layui-btn layui-btn-primary" href="#">批量修改</a>-->
            </span>
        </div>

    <table class="layui-hide" id="test" lay-filter="test"></table>
    <script type="text/html" id="barDemo">
        <betton  class="layui-btn layui-btn-normal layui-btn-xs " lay-event="edit"  >审核</betton>
    </script>
    </div>
</div>
    <script type="text/javascript">
        layui.use(['layer','form','table'], function(){
            var form = layui.form;
            var table = layui.table;
            var layer = layui.layer;
            var $ = layui.jquery;
            table.render({
                even: true,//开启隔行背景
                size: 'sm',//小尺寸的表格
                toolbar: '#toolbarDemo',
                elem: '#test',
                url: '${base}/comCar/select',
                title: '用户数据表',
                cols: [[
                    {type: 'checkbox',width:40}
                    ,{field:'ptName', title: '已认证企业',align:'center'}
                    ,{field:'callName', title: '企业姓名',align:'center', templet: '#phoneTpl'}
                    ,{field:'callPhone', title: '联系人手机号',align: 'center'}
                    ,{field: 'carType', title: '车型', align: 'center'}
                    // ,{field: 'carNumber', title: '车牌号', align: 'center'}
                    ,{field: 'num', title: '数量', align: 'center'}
                    ,{field:'isShow', title: '是否通过',align:'center'
                        ,
                        templet:function(val){
                            var isShow=val.isShow;
                            if(isShow==2){
                                return "不通过"
                            }else{
                                return"通过"
                            }
                        }
                    }
                    ,{field:'cause', title: '未通过原因', align:'center'}
                    ,{field:'ma', title: '操作', align:'center', toolbar: '#barDemo'}
                ]]
                ,height:480
                ,id: 'testReload'
                ,height:480
                ,page: {
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                    ,theme: '#9AC747'
                    ,limit: 10
                }
            });

            //页面传参
            table.on('tool(test)', function(obj){
                var layEvent = obj.event;
                if(layEvent=="edit"){
                    var data = obj.data;
                    //示范一个公告层
                    layer.open({
                        type: 2,
                        title: '编辑',
                        shadeClose:false ,
                        offset: 't',
                        area:['100%','100%'],
                        content:
                        '${base}/comCar/check.html?peoepleUrla='
                        +data.peoepleUrla+
                        '&id='
                        +data.id,
                        success: function (layero, index) {
                            //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            var iframeWin = window[layero.find('iframe')[0]['name']];
                            iframeWin.$("#num").val(data.num);
                            iframeWin.$("#callName").val(data.callName);
                            iframeWin.$("#carType").val(data.carType);
                            iframeWin.$("#ptName").val(data.ptName);
                            iframeWin.$("#callPhone").val(data.callPhone);
                            // iframeWin.$("#carNumber").val(data.carNumber);
                            iframeWin.$("#cause").val(data.cause);
                            iframeWin.$("#carBrand").val(data.carBrand);
                            iframeWin.$("#certificate").val(data.certificate);
                            iframeWin.$("#id").val(data.id);


                            //渲染一下form表单
                            iframeWin.layui.form.render('select');
                            iframeWin.layui.form.render();
                        }
                    });
                }

            });

        });


        function deleteAll(){
            var table=layui.table;
            var checkStatus = table.checkStatus('testReload');
            var tableData=checkStatus.data;
            var ids=[];
            for( var i=0;i<tableData.length;i++){
                ids.push(tableData[i].id);
            }

            console.log(ids)
            $.ajax({
                type: "POST",
                data:{ids:ids},
                url: "${base}/comCar/deleteAll",

                success: function (data) {
                    var table = layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/comCar/select',
                        where: {} //设定异步数据接口的额外参数
                    });
                    layer.close(index);
                }

            });
        }
    </script>
</body>
</html>
